/*
 * @Description: 四性检测结果页
 * @Author: Zzt
 * @Date: 2022-10-09 11:04:19
 * @LastEditTime: 2022-10-24 15:22:02
 */
import { Button, Descriptions, Modal, Tag } from 'antd';
import styles from './styles/result.module.scss';
import classNames from 'classnames/bind';
import { useMemo, useState } from 'react';
import EEPError from './conponentes/EEPError';
import OriginalEntryError from './conponentes/OriginalEntryError';
import Statistics from './conponentes/Statistics';
import { formatDate } from '@/utils';
const cx = classNames.bind(styles);
const test = {
  name: '20210628-1',
  type: '文书档案',
  num: 50,
  result: false,
  men: 'XXX',
  startTime: 'XXXX-XX-XX',
  finshTime: 'XXXX-XX-XX',
  module: '条目接受检测',
  remark: 'Loren ipsum',
  carrier: 'a'
};
interface IDetectionResultPrpos {
  visible: boolean;
  onClose: any;
  list: any;
}
const DetectionResult = (props: IDetectionResultPrpos) => {
  const { visible, onClose, list } = props;
  console.log(list);
  const {
    detectionJobVO,
    detectionResultEnvironment,
    detectionTemplate,
    showDetectionResultType,
    detectionResultArchives
  } = list;
  const [statisticsVisible, setStatisticsVisible] = useState(false);
  return (
    <Modal visible={visible} title={'四性检测结果'} width={900} footer={null} onCancel={onClose}>
      <div>
        <div>
          <div className={cx('result-base')}>
            <div className={cx('result-information')}>基本信息</div>
          </div>
          <div className={cx('result-show')}>
            <Descriptions labelStyle={{ fontWeight: 'bold' }}>
              <Descriptions.Item label="检测名称" span={3}>
                {detectionJobVO.name}
              </Descriptions.Item>
              <Descriptions.Item label="档案类型">
                {detectionJobVO.archiveTypeName}
              </Descriptions.Item>
              <Descriptions.Item label="检测结果" span={2}>
                {detectionJobVO.status === 3 ? (
                  <Tag color="green">通过</Tag>
                ) : (
                  <Tag color="red">失败</Tag>
                )}
              </Descriptions.Item>
              <Descriptions.Item label="检测人">{detectionJobVO.operatorName}</Descriptions.Item>
              <Descriptions.Item label="检测时间">
                {formatDate(detectionJobVO.startTime)}
              </Descriptions.Item>
              <Descriptions.Item label="检测完成时间">
                {formatDate(detectionJobVO.endTime)}
              </Descriptions.Item>
              <Descriptions.Item label="检测方案模板" span={3}>
                {detectionTemplate.templateName}
              </Descriptions.Item>
              <Descriptions.Item label="备注" span={3}>
                {detectionTemplate.templateDesc}
              </Descriptions.Item>
            </Descriptions>
          </div>
        </div>
        <div>
          {showDetectionResultType === 1 && detectionJobVO.status !== 3 && (
            // {showDetectionResultType === 1 && (
            <EEPError detectionResultEnvironment={detectionResultEnvironment} />
          )}
          {showDetectionResultType === 2 && (
            <OriginalEntryError
              onOpen={() => setStatisticsVisible(true)}
              detectionResultArchives={detectionResultArchives}
            />
          )}
        </div>
      </div>
      {useMemo(
        () => (
          <Statistics
            visible={statisticsVisible}
            detectionResultArchives={detectionResultArchives}
            onClose={() => setStatisticsVisible(false)}
          />
        ),
        [statisticsVisible]
      )}
    </Modal>
  );
};
export default DetectionResult;
